<?php

if (validation_errors()) :
?>
<section class="content-header">
<div class='alert alert-block alert-error fade in'>
    <a class='close' data-dismiss='alert'>&times;</a>
    <h4 class='alert-heading'>
        <?php echo lang('channel_errors_message'); ?>
    </h4>
    <?php echo validation_errors(); ?>
</div>
</section>
<?php
endif;

$id = isset($channel->id) ? $channel->id : '';

?>

<!-- <section class="content-header">
      <h1>
        General Form Elements
        <small>Preview</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Forms</a></li>
        <li class="active">General Elements</li>
      </ol>
    </section> -->

<!-- Main content -->
<section class="content">
  <div class="row">
    <div class="col-xs-12">
        <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">编辑户型</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <?php echo form_open($this->uri->uri_string(), 'class="form-horizontal"'); ?>
              <div class="box-body">
                <div class="form-group">
                  <?php echo form_label('户型图片', '', array('class'=>'col-sm-2 control-label')); ?>
<!--                   <div class="col-md-10">
                        <div id="container">
                            <a class="btn btn-default btn-lg " id="huxing_pickfiles" href="#" >
                                <i class="glyphicon glyphicon-plus"></i>
                                <span>选择图片</span>
                            </a>
                        </div>
                    </div> -->
                <div class="col-md-10">
                    <div id="container">
                                      &nbsp;&nbsp;&nbsp;
                                      <a class="btn btn-default btn-lg " id="pc_pickfiles" href="#" >
                                          <i class="glyphicon glyphicon-plus"></i>
                                              <span>桌面端</span>
                                      </a>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                      <a class="btn btn-default btn-lg " id="mobile_pickfiles" href="#" >
                                          <i class="glyphicon glyphicon-plus"></i>
                                              <span>移动端</span>
                                      </a>
                                  </div>
                    </div>

                </div>

                <div class="form-group">
                  <?php echo form_label('户型名称' . lang('bf_form_label_required'), 'name', array('class'=>'col-sm-2 control-label')); ?>
                  <div class="col-sm-10">
                  <input id='name' type='text' required='required' name='name' class="form-control" maxlength='100' value="<?php echo set_value('name', isset($huxing->name) ? $huxing->name : ''); ?>"/>
                  </div>
                </div>

                <div class="form-group">
                  <?php echo form_label('户型描述', 'desc', array('class'=>'col-sm-2 control-label')); ?>
                    <div class="col-sm-10">
                    <textarea id='desc' name='desc' class="form-control"><?php echo set_value('desc', isset($huxing->desc) ? $huxing->desc : ''); ?></textarea>
                    </div>
                </div>

                <div class="form-group">
                  <?php echo form_label('户型', 'room', array('class'=>'col-sm-2 control-label')); ?>
                    <div class="col-sm-10">
                        <select class="form-control select2" style="width: 100%;" name="room" id="huxing_room">
                          <option selected="selected" value="0">选择户型</option>
                          <?php foreach ($rooms as $key => $room) : ?>
                          <option value="<?php echo $key; ?>" <?php echo set_select('room', $key, (isset($huxing->room) ? $huxing->room : '')==$key); ?>><?php echo $room; ?></option>
                        <?php endforeach; ?>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                  <?php echo form_label('均价', 'price', array('class'=>'col-sm-2 control-label')); ?>
                    <div class="col-sm-3">
                      <input id='price' type='text' name='price' class="form-control" maxlength='100' value="<?php echo set_value('price', isset($huxing->price) ? $huxing->price : ''); ?>" placeholder="单位：元/平米"/>
                    </div>
                    <?php echo form_label('促销价', 'sale_price', array('class'=>'control-label', 'style'=>'float:left;')); ?>
                    <div class="col-sm-3">
                      <input id='sale_price' type='text' name='sale_price' class="form-control" maxlength='100' value="<?php echo set_value('sale_price', isset($huxing->sale_price) ? $huxing->sale_price : ''); ?>" placeholder="单位：元/平米"/>
                    </div>

                    <div class="col-sm-2">
                        <select class="form-control select2" style="width: 100%;" name="sub_type" id="huxing_room_type">
                          <?php foreach ($roomsType as $key => $roomType) : ?>
                          <option value="<?php echo $key; ?>" <?php echo set_select('room_type', $key, (isset($huxing->sub_type) ? $huxing->sub_type : '')==$key); ?>><?php echo $roomType; ?></option>
                        <?php endforeach; ?>
                        </select>
                    </div>

                    <div class="col-sm-1">
                        <input type="checkbox" class="minimal" name="is_sale" id="is_sale" <?php if (isset($huxing->is_sale) && $huxing->is_sale==1): ?>checked<?php endif; ?> />
                        <?php echo form_label('促销', 'is_sale', array()); ?>
                    </div>

                </div>

                <div class="form-group">
                  <?php echo form_label('桌面端图片', 'pic', array('class'=>'col-sm-2 control-label')); ?>
                    <div class="col-sm-10" id="huxing_pic_list_pc">
                     <?php if($huxing->photos_pc) : ?>
                    <?php foreach ($huxing->photos_pc as $photo) : ?>
                    <div style="float: left;"><img src="<?php echo $photo->absolute_url ?>" width="100" style="padding-right:5px;"><p style="text-align: center;"><a href="javascript:;" onclick="delHuxingPhoto($(this));">删除</a></p><input type="hidden" name="url[]" value="<?php echo $photo->url ?>" style="display:none;"><input type="hidden" name="platform[]" value="1" style="display:none;" /></div>
                    <?php endforeach; ?>
                    <?php endif; ?>
                    </div>
                </div>

                  <div class="form-group">
                  <?php echo form_label('移动端图片', 'pic', array('class'=>'col-sm-2 control-label')); ?>
                    <div class="col-sm-10" id="huxing_pic_list_mobile">
                    <?php if(isset($huxing->photos_mobile)) : ?>
                    <?php foreach ($huxing->photos_mobile as $photo) : ?>
                    <div style="float: left;"><img src="<?php echo $photo->absolute_url ?>" width="100" style="padding-right:5px;"><p style="text-align: center;"><a href="javascript:;" onclick="delHuxingPhoto($(this));">删除</a></p><input type="hidden" name="url[]" value="<?php echo $photo->url ?>" style="display:none;"><input type="hidden" name="platform[]" value="2" style="display:none;" /></div>
                    <?php endforeach; ?>
                    <?php endif; ?>
                    </div>
                </div>

              </div>
              <!-- /.box-body -->

              <div class="box-footer">
                <input type="hidden" name="building_id" value="<?php echo $buildingId; ?>" style="display:none;" />
                <button type="submit" name='save' class="btn btn-primary"><?php echo lang('bf_action_save'); ?></button>
                <?php echo anchor('/buildings/bhuxing/index/'.$buildingId.'/', lang('bf_action_cancel'), 'class="btn btn-default pull-right"'); ?>
              </div>
            <?php echo form_close(); ?>
          </div>

          </div>
      </div>
</section>
